#include "StdAfx.h"
#include "Prepare.h"
#include "Check.h"
#include "../macro.h"

Prepare::Prepare(void)
{
}

Prepare::~Prepare(void)
{
}


bool Prepare::addCheck(Check* checker)
{
	if (checker==NULL)
	{
		return false;
	}

	m_checkers.push_back(checker);
	return true;
}
bool Prepare::delCheck(int index)
{
	if (index>=m_checkers.size())
	{
		return false;
	}

	int id_of_list = 0;
	for (std::vector<Check*>::iterator iter=m_checkers.begin();iter!=m_checkers.end();++iter,++id_of_list)
	{
		if (index == id_of_list)
		{
			m_checkers.erase(iter);
			break;
		}
	}
	return true;
}

bool Prepare::run(void* param)
{
	DBG_PRINTF("%s\r\n",__FUNCTION__);

	for (std::vector<Check*>::iterator iter=m_checkers.begin(); iter!=m_checkers.end();++iter)
	{
		if ((*iter)!=NULL)
		{
			if (!(*iter)->run(param))
			{
				return false;
			}
		}
	}
	return true;
}